var vm =  new Vue({
		el:"#app",
		data:{
			username:'',
			password:'',
			url:'userMian.html',
			uName:'',
			uId:0
		},
		methods:{
			setCookie: function (cname, cvalue, exdays) {
		        var d = new Date();
		        d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000));
		        var expires = "expires=" + d.toUTCString();
		        console.info(cname + "=" + cvalue + "; " + expires);
		        document.cookie = cname + "=" + cvalue + "; " + expires;
		        console.info(document.cookie);
			},
			
			getCookie: function (cname) {
		        var name = cname + "=";
		        var ca = document.cookie.split(';');
		        console.log("获取cookie,现在循环")
		        for (var i = 0; i < ca.length; i++) {
		          var c = ca[i];
		          console.log(c)
		          while (c.charAt(0) == ' ') c = c.substring(1);
		          if (c.indexOf(name) != -1){
		            return c.substring(name.length, c.length);
		          }
		        }
		        return "";
      		},
      		
      		 clearCookie: function (username) {
        		this.setCookie(username, "", -1);
      		},
      		
      		
		    checkCookie: function () {
		        var user = this.getCookie("username");
		        if (user != "") {
		          alert("Welcome again " + user);
		        } else {
		          user = prompt("Please enter your name:", "");
		          if (user != "" && user != null) {
		            this.setCookie("username", user, 365);
		          }
		        }
		    },
			
			login: function(e){
				var _this = this;
				console.log(local___Path)
				$.ajax({
					type: "POST",
		             url: ___Path +  "/user/login.json?username="+_this.username+"&password="+_this.password,
		             data: null,
		             contentType: "application/json",
		             dataType: "json",
					success: function(result){
						if(result.data.user!=null){
							_this.setCookie("user",result.data.user.id,1);
							_this.setCookie("userName",result.data.user.username,1);
							_this.setCookie("phone",result.data.user.phone,1);
							setTimeout(function(){ 
								window.location.href = projectName +  "/fileManage.html";
							}, 1000);
						}
						alert(result.msg.msgText);
					},
					error: function(){
						alert("连接错误");
					}
				});
				
//				while(status == null){
//					
//					if(status == true){
//						break;
//					}
//					if(status == false){
//						alert(text)
//						break;
//					}
//				
//				}
//				return status;
				return false;
			},
			
			login2:function(){
				
			}
		}
});